import request from '@/config/axios'
import {ServicePrefixEnum} from "@/enums/commonEnum";
import {RequestEnum} from "@/enums/httpEnum";
import {defHttp} from "@/utils/http/axios";
import type { AxiosRequestConfig } from 'axios';
export type DictDataVO = {
  id: number | undefined
  sort: number | undefined
  label: string
  value: string
  dictType: string
  status: number
  colorType: string
  cssClass: string
  remark: string
  createTime: Date
}

const  MODULAR = '/system/dict-data'
export const Api = {
  GetSimpleDictDataList: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/simple-list`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetDictDataPage: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetDictData: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  CreateDictData: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/create`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  UpdateDictData: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  DeleteDictData: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/delete`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,

}

// 查询字典数据（精简)列表
export const getSimpleDictDataList = () => {
  return defHttp.request({ ...Api.GetSimpleDictDataList })
}

// 查询字典数据列表
export const getDictDataPage = (params: PageParam) => {
  return defHttp.request({ ...Api.GetDictDataPage, params:params })
}

// 查询字典数据详情
export const getDictData = (id: number) => {
  let params = { id: id }
  return defHttp.request({ ...Api.GetDictData, params:params})
}

// 新增字典数据
export const createDictData = (data: DictDataVO) => {
  let params = {data :data}
  return defHttp.request({ ...Api.CreateDictData, params:params })
}

// 修改字典数据
export const updateDictData = (data: DictDataVO) => {
  let  params = {data :data}
  return  defHttp.request({ ...Api.UpdateDictData, params:params })
}

// 删除字典数据
export const deleteDictData = (id: number) => {
  let params = { id: id }
  return defHttp.request({ ...Api.DeleteDictData, params:params })
}



// 导出字典类型数据
//TODO
export const exportDictData = (params) => {
  return request.download({ url: '/system/dict-data/export', params })
}
